#include <stdio.h>
#include <stdlib.h>

#define MaxTree 10 /* maximum number of nodes in a tree */
typedef int ElementType;

typedef struct TreeNode*Tree;
struct TreeNode
{
    ElementType Element;
    Tree        Left;
    Tree        Right;
};

Tree BuildTree()
{return NULL;} /* details omitted */
void PrintNode(Tree NodePtr)
{
    printf(" %d",NodePtr->Element);
}

void Level_order(Tree T,void (*visit)(Tree ThisNode));

int main()
{
    Tree T=BuildTree();
    printf("Level-order:");
    Level_order(T,PrintNode);
    return 0;
}

/* Your function will be put here */
Tree queue[MaxTree+10];
int  head=0,tail=0;

void push(Tree node)
{
    if(node)
        queue[tail++]=node;
}

int empty(void)
{
    return head==tail;
}

Tree pop(void)
{
    return queue[head++];
}

void Level_order(Tree T,void (*visit)(Tree ThisNode))
{
    push(T);
    while(!empty())
    {
        Tree t=pop();
        push(t->Left);
        push(t->Right);
        visit(t);
    }
}